//
//  SettingInterfaceViewController.m
//  ProjectA
//
//  Created by dlios on 15/3/5.
//  Copyright (c) 2015年 dlios. All rights reserved.
//

#import "SettingInterfaceViewController.h"

@interface SettingInterfaceViewController ()

@end

@implementation SettingInterfaceViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"我  的";
    
    
    
//HEAD IMAGE VIEW
    self.headImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user-background.jpg"]];
    self.headImageView.frame = CGRectMake(0, 0, self.view.frame.size.width, 290);
    
    
    [self.view addSubview:self.headImageView];
    
    
//USER IMAGEVIEW
    self.userImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"userHead.png"]];
    self.userImageView.frame = CGRectMake(0, 0, 100 , 100);
    self.userImageView.center = CGPointMake(self.view.center.x, 160);
    
    
    
//添加手势
    UIGestureRecognizer *gesture1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    
    self.userImageView.userInteractionEnabled = YES;  //开启交互
    
    [self.userImageView addGestureRecognizer:gesture1];
    
    
    [self.view addSubview:self.userImageView];
    
    
//提示语
    UIButton *loginButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    loginButton.frame = CGRectMake(0, self.userImageView.frame.size.height + self.userImageView.frame.origin.y + 10, self.view.frame.size.width, 50);
    [loginButton setTitle:@"点击头像登陆" forState:(UIControlStateNormal)];
    [loginButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    
    [self.view addSubview:loginButton];
    

    
//TABLEVIEW
    UITableView *tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 320, self.view.frame.size.width, 160) style:(UITableViewStylePlain)];
    
    tableview.delegate = self;
    tableview.dataSource = self;
    tableview.scrollEnabled = NO;
    
//    [tableview setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
    
    [self.view addSubview:tableview];
    
    
    
} //DID LOAD ***


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}//section number


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 50;
}//height


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 3;
    
} //row number


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *identify = @"reuse";
    
    UserPageCell *cell = [tableView dequeueReusableCellWithIdentifier:identify];
    
    if ( cell == nil) {
        cell = [[UserPageCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:identify    ];
        
    }
    
    if (0 == indexPath.row) {
        cell.imageview.image = [UIImage imageNamed:@"Favorites.png"];
        cell.titleLabel.text = @"我的收藏";
        
    }else if (1 == indexPath.row){
        
        cell.imageview.image = [UIImage imageNamed:@"ClearCache.png"];
        cell.titleLabel.text = @"清除缓存";
        
    }else if (2 == indexPath.row){
        
        cell.imageview.image = [UIImage imageNamed:@"aboutUs.png"];
        cell.titleLabel.text = @"关于我们";
    }
    
    
    return  cell;
    
} //cell


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        
        MineResaveViewController *mineResave = [[MineResaveViewController alloc]init];
        [self.navigationController pushViewController:mineResave animated:YES];
        
        
    }
    
    
}//选中触发方法


-(void)tapAction:(UITapGestureRecognizer *)sender{
    
    NSLog(@"tap");
    
}//头像轻拍手势



@end













